formatRate

fun formatRate(rate: Double, decimalChar: Char, defaultMaxDecPlaces: Int? = null, fillZeroes: Boolean = false): String

Formats the given value (rate/price) into a string, rounding according to this currency/security's priceDisplayDecimalPlaces setting. When both priceDisplayDecimalPlaces and defaultMaxDecPlaces (defaults) are null then no rounding will take place.

Since

Moneydance 2024.3

Return

Returns a formatted rate/price (rounded when priceDisplayDecimalPlaces or defaultMaxDecPlaces is set) - for display purposes only.

Parameters

rate

The rate/price to format

decimalChar

The dot/comma decimal character to be used in the returned formatted string

defaultMaxDecPlaces

Optional: allows default maximum (null/zero/positive) decimal places to be specified for rounding/display when no priceDisplayDecimalPlaces has been set on this currency/security

fillZeroes

When true will return a fixed width decimal result. When false (default) the decimal portion might be shortened where there are less fractional digits.